home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / Converters / HP2TeX.lha / hp2tex.rexx next >
Encoding:
OS/2 REXX Batch file  |  1996-03-22  |  5.6 KB  |  155 lines

  1. /* HP11C (FF274) to TeX V1.0 */
  2. /* © by Stefan Haubenthal 1995/96 */
  3. call open source,arg(1)
  4. call seek source,-1,E
  5. len=c2d(readch(source))
  6. call seek source,x2d("ea"),B
  7. say "%"sourceline(1)
  8. say "% "arg(1)
  9. say "\nopagenumbers"
  10. cmd.000="$\sqrt x$" /* square root */
  11. cmd.001="$e^x$"
  12. cmd.002="$10^x$"
  13. cmd.003="$y^x$" /* power of */
  14. cmd.004="$1/x$"
  15. cmd.005="CHS" /* change sign */
  16. cmd.006="$\div$"
  17. cmd.007="SIN"
  18. cmd.008="COS"
  19. cmd.009="TAN"
  20. cmd.00A="EEX" /* exponent */
  21. cmd.00B="$\times$"
  22. cmd.00C="R/S" /* run/stop */
  23. cmd.00D="R$\downarrow$" /* roll down */
  24. cmd.00E="$x\leftrightarrow y$" /* x versus y */
  25. cmd.00F="ENTER" /* enter */
  26. cmd.010="$-$" /* minus */
  27. cmd.011="." /* point */
  28. cmd.012="$\Sigma$+" /* add (x,y) */
  29. cmd.013="+" /* plus */
  30. cmd.014="$\pi$"
  31. cmd.015="$x\le y$"
  32. cmd.016="$x\leftrightarrow (i)$" /* x versus (i) */
  33. cmd.017="$\to$R"
  34. cmd.018="$x\leftrightarrow$ I" /* x versus I */
  35. cmd.019="DSE" /* decrement and skip if equal */
  36. cmd.01A="ISG" /* increment and skip if greater */
  37. cmd.01B="$x>y$"
  38. cmd.01C="PSE" /* pause */
  39. cmd.01D="CLEAR-$\Sigma$" /* clear statistics */
  40. cmd.01E="CLEAR-REG" /* clear registers */
  41. cmd.01F="RAN\#" /* random number */
  42. cmd.020="P$y,x$"
  43. cmd.021="$\to$H.MS" /* hours minutes seconds */
  44. cmd.022="$\to$RAD"
  45. cmd.023="$x\ne y$" /* x not equal y */
  46. cmd.025="$x!$" /* factorial */
  47. cmd.024="FRAC" /* fractional */
  48. cmd.026="$\hat y,r$" /* estimation, correlation */
  49. cmd.027="L.R." /* linear regression */
  50. cmd.028="$x=y$" /* x equal y */
  51. cmd.029="$x^2$" /* square */
  52. cmd.02A="LN" /* logarithmus naturalis */
  53. cmd.02B="LOG" /* logarithmus */
  54. cmd.02C="\%" /* per cent */
  55. cmd.02D="$\Delta$\%" /* per cent change */
  56. cmd.02E="ABS" /* absolute */
  57. cmd.02F="DEG" /* degree */
  58. cmd.030="RAD" /* radian */
  59. cmd.031="GRD" /* grad */
  60. cmd.032="$x<0$" /* x lower than zero */
  61. cmd.033="SIN$^{-1}$"
  62. cmd.034="COS$^{-1}$"
  63. cmd.035="TAN$^{-1}$"
  64. cmd.036="$\to$P"
  65. cmd.037="$x>0$" /* greater then zero */
  66. cmd.038="RTN" /* return */
  67. cmd.039="R$\uparrow$" /* roll up */
  68. cmd.03A="RND" /* round */
  69. cmd.03B="CLX" /* clear x */
  70. cmd.03C="LST X" /* last x */
  71. cmd.03D="C$y,x$"
  72. cmd.03E="$\to$H"
  73. cmd.03F="$\to$DEG"
  74. cmd.040="$x\ne0$" /* x not equal zero */
  75. cmd.041="INT" /* integer */
  76. cmd.042="$\bar x$" /* mean */
  77. cmd.043="$s$" /* sdev */
  78. cmd.044="$\Sigma-$" /* sub (x,y) */
  79. cmd.045="$x=0$" /* x equal zero */
  80. cmd.046="RCL ENTER" /* recall enter */
  81. cmd.047="RCL $\Sigma$+"
  82. cmd.048="HYP SIN"
  83. cmd.049="HYP COS"
  84. cmd.04A="HYP TAN"
  85. cmd.04B="HYP$^{-1}$ SIN"
  86. cmd.04C="HYP$^{-1}$ COS"
  87. cmd.04D="HYP$^{-1}$ TAN"
  88. cmd.04E="SF 0" /* set flag 0 */
  89. cmd.04F="SF 1" /* set flag 1 */
  90. cmd.050="CF 0" /* clear flag 0 */
  91. cmd.051="CF 1" /* clear flag 1 */
  92. cmd.052="F? 0" /* test flag 0 */
  93. cmd.053="F? 1" /* test flag 1 */
  94. do i=1 to len
  95. step=right(c2x(readch(source,2)),3)
  96. if i//5=0 then call writech stdout,"\item{"i":}{"
  97.       else call writech stdout,"\par{"
  98. select
  99.     when step<=053 then say value("cmd."step)"}"
  100.     when step>=054 & step<=05D then say "\it"x2d(step)-84"}" /* digit */
  101.     when step>=05E & step<=067 then say "FIX" x2d(step)-94"}" /* fixed */
  102.     when step>=068 & step<=06F then say "SCI" x2d(step)-104"}" /* scientific */
  103.     when step>=070 & step<=077 then say "ENG" x2d(step)-112"}" /* engineering */
  104.     when step>=078 & step<=081 then say "LBL" d2c(x2d(step)-72)"}" /* label digit */
  105.     when step>=082 & step<=086 then say "LBL" d2c(x2d(step)-65)"}" /* label letter */
  106.     when step>=087 & step<=090 then say "GTO" d2c(x2d(step)-87)"}" /* goto digit */
  107.     when step>=091 & step<=095 then say "GTO" d2c(x2d(step)-80)"}" /* goto letter */
  108.     when step=096 then say "GTO I}"
  109.     when step>=097 & step<=0A0 then say "GSB" d2c(x2d(step)-103)"}" /* gosub digit */
  110.     when step>=0A1 & step<=0A5 then say "GSB" d2c(x2d(step)-96)"}" /* gosub letter */
  111.     when step=0A6 then say "GSB I}"
  112.     when step>=0A7 & step<=0B0 then say "STO" d2c(x2d(step)-119)"}" /* store digit */
  113.     when step>=0B1 & step<=0BA then say "STO ." d2c(x2d(step)-129)"}" /* store point digit */
  114.     when step=0BB then say "STO I}" /* store I */
  115.     when step=0BC then say "STO $(i)$}" /* store (i) */
  116.     when step>=0BD & step<=0C6 then say "STO +" d2c(x2d(step)-141)"}" /* store plus digit */
  117.     when step>=0C7 & step<=0D0 then say "STO + ." d2c(x2d(step)-151)"}" /* store plus point digit */
  118.     when step=0D1 then say "STO + I}" /* store plus I */
  119.     when step=0D2 then say "STO + $(i)$}" /* store plus (i) */
  120.     when step>=0D3 & step<=0DC then say "STO -" d2c(x2d(step)-163)"}" /* store minus digit */
  121.     when step>=0DD & step<=0E6 then say "STO - ." d2c(x2d(step)-173)"}" /* store minus point digit */
  122.     when step=0E7 then say "STO - I}" /* store minus I */
  123.     when step=0E8 then say "STO - $(i)$}" /* store minus (i) */
  124.     when step>=0E9 & step<=0F2 then say "STO $\times$" d2c(x2d(step)-185)"}" /* store mult digit */
  125.     when step>=0F3 & step<=0FC then say "STO $\times$ ." d2c(x2d(step)-195)"}" /* store mult point digit */
  126.     when step=0FD then say "STO $\times$ I}" /* store mult I */
  127.     when step=0FE then say "STO $\times$ $(i)$}" /* store mult (i) */
  128.     when step>=0FF & step<=108 then say "STO $\div$" d2c(x2d(step)-207)"}" /* store div digit */
  129.     when step>=109 & step<=112 then say "STO $\div$ ." d2c(x2d(step)-217)"}" /* store div point digit */
  130.     when step=113 then say "STO $\div$ I}" /* store div I */
  131.     when step=114 then say "STO $\div$ $(i)$}" /* store div (i) */
  132.     when step>=115 & step<=11E then say "RCL" d2c(x2d(step)-229)"}" /* recall digit */
  133.     when step>=11F & step<=128 then say "RCL ." d2c(x2d(step)-239)"}" /* recall point digit */
  134.     when step=129 then say "RCL I}" /* recall I */
  135.     when step=12A then say "RCL $(i)$}" /* recall (i) */
  136.     otherwise say step"?}"
  137. end
  138. end
  139. say "\bye"
  140. /*
  141. Modes:
  142. P/R    program/run
  143. USER    user
  144. ON    power on
  145. MEM    memory
  146. CLEAR-PREFIX    clear prefix
  147.  
  148. Edit:
  149. <-    delete
  150. SST    single step
  151. BST    back step
  152. GTO.xxx    goto step xxx
  153. CLEAR-PRGM    clear program
  154. */
  155.